package jsyf.oa.web.report.visitCustomer;

import com.alibaba.fastjson.JSONObject;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import jsyf.com.util.BaseUtils;
import jsyf.com.util.FastJsonConvert;
import jsyf.com.util.ResponseUtils;
import jsyf.oa.facade.report.visitCustomer.VisitCustomerFacade;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * Created by jjx on 2018/4/6.
 */
@Api(value = "新的拜访客户", description = "新的拜访客户")
@Controller
@RequestMapping("/visitCustomer")
public class VisitCustomerController {

    @Resource
    private VisitCustomerFacade visitCustomerFacade;

    @ResponseBody
    @RequestMapping(value = "/getPeopleByUserId.json", method = RequestMethod.POST)
    @ApiOperation(
            value = "点击区域经理名字--查看拜访的客户",
            notes = "查看区域经理详情拜访",
            httpMethod = "POST",
            produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiImplicitParam(name = "jsonData", value = "{userId,dateTime}", dataType = "String", paramType = "body")
    public void getPeopleByUserId(HttpServletRequest request, HttpServletResponse response, @RequestBody String jsonData) {
        JSONObject records = this.visitCustomerFacade.getPeopleByUserId(jsonData);
        ResponseUtils.putJsonResponse(response, BaseUtils.succsessArrHourTimeRespond(records));
    }

    @RequestMapping(value = "/getRegionInfo.json", method = RequestMethod.POST)
    @ApiOperation(
            value = "部门层目标完成",
            notes = "部门层目标完成",
            httpMethod = "POST",
            response = ResponseUtils.class,
            produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "jsonData", value = "{dateTime:'',userId:''}", dataType = "String", paramType = "body")
    })
    public void getRegionInfo(HttpServletRequest request, HttpServletResponse response, @RequestBody String jsonData) {
        JSONObject records = this.visitCustomerFacade.getRegionInfo(jsonData);
        ResponseUtils.putJsonResponse(response, BaseUtils.succsessObjRespond(records));
    }

    @RequestMapping(value = "/getForPersonal.json", method = RequestMethod.POST)
    @ApiOperation(
            value = "区域经理--查看拜访客户",
            notes = "新的拜访个人层",
            httpMethod = "POST",
            response = ResponseUtils.class,
            produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "jsonData", value = "{dateTime,userId,type}", dataType = "String", paramType = "body")
    })
    public void getForPersonal(HttpServletRequest request, HttpServletResponse response, @RequestBody String jsonData) {
        List<JSONObject> records = this.visitCustomerFacade.getForPersonalByUserId(jsonData);
        ResponseUtils.putJsonResponse(response, BaseUtils.succsessArrRespond(records));
    }


    @RequestMapping(value = "/getForDepart.json", method = RequestMethod.POST)
    @ApiOperation(
            value = "大区经理->总经理--查看拜访客户",
            notes = "新的拜访部门层",
            httpMethod = "POST",
            response = ResponseUtils.class,
            produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "jsonData", value = "{dateTime,userId,type}", dataType = "String", paramType = "body")
    })
    public void getForDepart(HttpServletRequest request, HttpServletResponse response, @RequestBody String jsonData) {
        List<JSONObject> records = this.visitCustomerFacade.getForDepart(jsonData);
        ResponseUtils.putJsonResponse(response, BaseUtils.succsessArrRespond(records));
    }

    @RequestMapping(value = "/getForBigCustomerDepart.json", method = RequestMethod.POST)
    @ApiOperation(
            value = "大客户总监，大客户经理",
            notes = "新的拜访部门层",
            httpMethod = "POST",
            response = ResponseUtils.class,
            produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "jsonData", value = "{dateTime,userId,type}", dataType = "String", paramType = "body")
    })
    public void getForBigCustomerDepart(HttpServletRequest request, HttpServletResponse response, @RequestBody String jsonData) {
        List<JSONObject> records = this.visitCustomerFacade.getForBigCustomerDepart(jsonData);
        ResponseUtils.putJsonResponse(response, BaseUtils.succsessArrRespond(records));
    }

    @RequestMapping(value = "/getForGroupByUserId.json", method = RequestMethod.POST)
    @ApiOperation(
            value = "集团大佬们查看拜访客户",
            notes = "集团",
            httpMethod = "POST",
            response = ResponseUtils.class,
            produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "jsonData", value = "{dateTime,userId,type}", dataType = "String", paramType = "body")
    })
    public void getForGroupByUserId(HttpServletRequest request, HttpServletResponse response, @RequestBody String jsonData) {
        List<JSONObject> records = this.visitCustomerFacade.getForGroupByUserId(jsonData);
        ResponseUtils.putJsonResponse(response, BaseUtils.succsessArrRespond(records));
    }


    @RequestMapping(value = "/getAllManagerByCompanyId.json", method = RequestMethod.POST)
    @ApiOperation(
            value = "点击区域名查看全部区域经理",
            notes = "公司下全部区域经理",
            httpMethod = "POST",
            response = ResponseUtils.class,
            produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "jsonData", value = "{dateTime,companyId,type}", dataType = "String", paramType = "body")
    })
    public void getAllManagerByCompanyId(HttpServletRequest request, HttpServletResponse response, @RequestBody String jsonData) {
        List<JSONObject> records = this.visitCustomerFacade.getAllManagerByCompanyId(jsonData);
        ResponseUtils.putJsonResponse(response, BaseUtils.succsessArrTimeRespond(records));
    }

    @RequestMapping(value = "/getAllBigCustomerManagerByCompanyId.json", method = RequestMethod.POST)
    @ApiOperation(
            value = "获取所有大客户经理",
            notes = "公司下全部区域经理",
            httpMethod = "POST",
            response = ResponseUtils.class,
            produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "jsonData", value = "{dateTime,companyId,type}", dataType = "String", paramType = "body")
    })
    public void getAllBigCustomerManagerByCompanyId(HttpServletRequest request, HttpServletResponse response, @RequestBody String jsonData) {
        List<JSONObject> records = this.visitCustomerFacade.getAllBigCustomerManagerByCompanyId(jsonData);
        ResponseUtils.putJsonResponse(response, BaseUtils.succsessArrRespond(records));
    }

    @RequestMapping(value = "/getBigCustomerForGroupByUserId.json", method = RequestMethod.POST)
    @ApiOperation(
            value = "点击区域名查看全部大客户经理",
            notes = "公司下大客户经理",
            httpMethod = "POST",
            response = ResponseUtils.class,
            produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "jsonData", value = "{dateTime,companyId,type}", dataType = "String", paramType = "body")
    })
    public void getBigCustomerForGroupByUserId(HttpServletRequest request, HttpServletResponse response, @RequestBody String jsonData) {
        List<JSONObject> records = this.visitCustomerFacade.getBigCustomerForGroupByUserId(jsonData);
        ResponseUtils.putJsonResponse(response, BaseUtils.succsessArrRespond(records));
    }

    @RequestMapping(value = "/getRegionByUserId.json", method = RequestMethod.POST)
    @ApiOperation(
            value = "获取可以查看的区域经理",
            notes = "取得所有区域经理，获取查看权",
            httpMethod = "POST",
            response = ResponseUtils.class,
            produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "jsonData", value = "{userId}", dataType = "String", paramType = "body")
    })
    public void getRegionByUserId(HttpServletRequest request, HttpServletResponse response, @RequestBody String jsonData) {
        List<JSONObject> records = this.visitCustomerFacade.getRegionByUserId(jsonData);
        ResponseUtils.putJsonResponse(response, BaseUtils.succsessArrRespond(records));
    }

    @RequestMapping(value = "/getCustomerByManage.json", method = RequestMethod.POST)
    @ApiOperation(
            value = "点击大区经理陪跑拜访数",
            notes = "大区经理陪跑详情",
            httpMethod = "POST",
            response = ResponseUtils.class,
            produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "jsonData", value = "{dateTime,userId,entourageId}", dataType = "String", paramType = "body")
    })
    public void getCustomerByManage(HttpServletRequest request, HttpServletResponse response, @RequestBody String jsonData) {
        List<JSONObject> records = this.visitCustomerFacade.getCustomerByManage(jsonData);
        ResponseUtils.putJsonResponse(response, BaseUtils.succsessArrRespond(records));
    }

    @RequestMapping(value = "/getManagerByUserId.json", method = RequestMethod.POST)
    @ApiOperation(
            value = "大区经理拜陪跑",
            notes = "大区经理拜访客户报表",
            httpMethod = "POST",
            response = ResponseUtils.class,
            produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "jsonData", value = "{dateTime,userId}", dataType = "String", paramType = "body")
    })
    public void getManagerByUserId(HttpServletRequest request, HttpServletResponse response, @RequestBody String jsonData) {
        List<JSONObject> records = this.visitCustomerFacade.getManagerByUserId(jsonData);
        ResponseUtils.putJsonResponse(response, BaseUtils.succsessArrRespond(records));
    }

    @ApiOperation(value = "点击客户名字--获取面访人详细信息", notes = "")
    @ApiImplicitParam(name = "jsonData", value = "{'id':'拜访id'}", dataType = "String", paramType = "body")
    @RequestMapping(value = "/getCustomerVisitById.json", method = RequestMethod.POST)
    public void getCustomerVisitById(HttpServletResponse response, @RequestBody String jsonData) {
        JSONObject jsonParam = FastJsonConvert.convertJSONToObject(jsonData, JSONObject.class);
        JSONObject id = visitCustomerFacade.getCustomerVisitById(jsonData);
        ResponseUtils.putJsonResponse(response, BaseUtils.succsessObjRespond(id));
    }

    @RequestMapping(value = "/getCompanyByUserId.json", method = RequestMethod.POST)
    @ApiOperation(
            value = "公司下大区经理陪跑",
            notes = "公司陪跑信息",
            httpMethod = "POST",
            response = ResponseUtils.class,
            produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "jsonData", value = "{dateTime,userId}", dataType = "String", paramType = "body")
    })
    public void getCompanyByUserId(HttpServletRequest request, HttpServletResponse response, @RequestBody String jsonData) {
        List<JSONObject> records = this.visitCustomerFacade.getCompanyByUserId(jsonData);
        ResponseUtils.putJsonResponse(response, BaseUtils.succsessArrRespond(records));
    }

    @RequestMapping(value = "/getForPersonalDayByUserIdAndDateTime.json", method = RequestMethod.POST)
    @ApiOperation(
            value = "今日大区经理报表--获取区域经理面访信息",
            notes = "今日大区经理报表--获取区域经理面访信息",
            httpMethod = "POST",
            response = ResponseUtils.class,
            produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "jsonData", value = "{userId}", dataType = "String", paramType = "body")
    })
    public void getForPersonalDayByUserIdAndDateTime(HttpServletRequest request, HttpServletResponse response, @RequestBody String jsonData) {
        List<JSONObject> records = this.visitCustomerFacade.getForPersonalDayByUserIdAndDateTime(jsonData);
        ResponseUtils.putJsonResponse(response, BaseUtils.succsessArrHourTimeRespond(records));
    }

    @RequestMapping(value = "/getForDepartByUserIdForClick.json", method = RequestMethod.POST)
    @ApiOperation(
            value = "部门级别拜访可以查看的大区名字",
            notes = "部门级别拜访可以查看的大区名字",
            httpMethod = "POST",
            response = ResponseUtils.class,
            produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "jsonData", value = "{userId}", dataType = "String", paramType = "body")
    })
    public void getForDepartByUserIdForClick(HttpServletRequest request, HttpServletResponse response, @RequestBody String jsonData) {
        List<JSONObject> records = this.visitCustomerFacade.getForDepartByUserIdForClick(jsonData);
        ResponseUtils.putJsonResponse(response, BaseUtils.succsessArrRespond(records));
    }

    @RequestMapping(value = "/getFirstVisitForPC.json", method = RequestMethod.POST)
    public void getFirstVisitForPC(HttpServletResponse response, @RequestBody String jsonData) {
        JSONObject result = this.visitCustomerFacade.getFirstVisitForPC(jsonData);
        ResponseUtils.putJsonResponse(response, BaseUtils.succsessArrHourTimeRespond(result));
    }

    @RequestMapping(value = "/getMonthVisitForPC.json", method = RequestMethod.POST)
    public void getMonthVisitForPC(HttpServletResponse response, @RequestBody String jsonData) {
        JSONObject result = this.visitCustomerFacade.getMonthVisitForPC(jsonData);
        ResponseUtils.putJsonResponse(response, BaseUtils.succsessArrHourTimeRespond(result));
    }

    @RequestMapping(value = "/stratAndEndFaceVisit.json", method = RequestMethod.POST)
    public void stratAndEndFaceVisit(HttpServletResponse response, @RequestBody String jsonData) {
        JSONObject result = this.visitCustomerFacade.stratAndEndFaceVisit(jsonData);
        ResponseUtils.putJsonResponse(response, BaseUtils.succsessArrHourTimeRespond(result));
    }

    @RequestMapping(value = "/getSignAndCustomerByUserId.json", method = RequestMethod.POST)
    public void getSignAndCustomerByUserId(HttpServletResponse response, @RequestBody String jsonData) {
        List<JSONObject> result = this.visitCustomerFacade.getSignAndCustomerByUserId(jsonData);
        ResponseUtils.putJsonResponse(response, BaseUtils.succsessArrTimeRespond(result));
    }

    @RequestMapping(value = "/getBigRegionManagerVisitForGroup.json", method = RequestMethod.POST)
    @ApiOperation(
            value = "集团获取大区经理拜访",
            notes = "集团获取大区经理拜访",
            httpMethod = "POST",
            response = ResponseUtils.class,
            produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "jsonData", value = "{dateTime,userId}", dataType = "String", paramType = "body")
    })
    public void getBigRegionManagerVisitForGroup(HttpServletRequest request, HttpServletResponse response, @RequestBody String jsonData) {
        List<JSONObject> records = this.visitCustomerFacade.getBigRegionManagerVisitForGroup(jsonData);
        ResponseUtils.putJsonResponse(response, BaseUtils.succsessArrRespond(records));
    }

    @RequestMapping(value = "/getBigRegionManagerVisitForDepart.json", method = RequestMethod.POST)
    @ApiOperation(
            value = "公司获取大区经理拜访",
            notes = "公司获取大区经理拜访",
            httpMethod = "POST",
            response = ResponseUtils.class,
            produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "jsonData", value = "{dateTime,userId}", dataType = "String", paramType = "body")
    })
    public void getBigRegionManagerVisitForDepart(HttpServletRequest request, HttpServletResponse response, @RequestBody String jsonData) {
        List<JSONObject> records = this.visitCustomerFacade.getBigRegionManagerVisitForDepart(jsonData);
        ResponseUtils.putJsonResponse(response, BaseUtils.succsessArrTimeRespond(records));
    }

    @RequestMapping(value = "/getBigRegionManagerPlanVisit.json", method = RequestMethod.POST)
    @ApiOperation(
            value = "公司获取大区经理面访计划",
            notes = "公司获取大区经理面访计划",
            httpMethod = "POST",
            response = ResponseUtils.class,
            produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "jsonData", value = "{dateTime,userId}", dataType = "String", paramType = "body")
    })
    public void getBigRegionManagerPlanVisit(HttpServletRequest request, HttpServletResponse response, @RequestBody String jsonData) {
        List<JSONObject> records = this.visitCustomerFacade.getBigRegionManagerPlanVisit(jsonData);
        ResponseUtils.putJsonResponse(response, BaseUtils.succsessArrRespond(records));
    }

    @RequestMapping(value = "/getBigRegionManagerFaceList.json", method = RequestMethod.POST)
    @ApiOperation(
            value = "公司获取大区经理面访列表",
            notes = "公司获取大区经理面访列表",
            httpMethod = "POST",
            response = ResponseUtils.class,
            produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "jsonData", value = "{dateTime,userId}", dataType = "String", paramType = "body")
    })
    public void getBigRegionManagerFaceList(HttpServletRequest request, HttpServletResponse response, @RequestBody String jsonData) {
        JSONObject records = this.visitCustomerFacade.getBigRegionManagerFaceList(jsonData);
        ResponseUtils.putJsonResponse(response, BaseUtils.succsessArrHourTimeRespond(records));
    }


    @RequestMapping(value = "/getRMTodayVisit.json", method = RequestMethod.POST)
    @ApiOperation(
            value = "区域经理今日拜访APP",
            notes = "区域经理今日拜访APP",
            httpMethod = "POST",
            produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiImplicitParam(name = "jsonData", value = "{'userId':'','dateTime':'yyyy-MM-dd'}", dataType = "String", paramType = "body")
    public void getRMTodayVisit(HttpServletResponse response, @RequestBody String jsonData) {
        JSONObject result = visitCustomerFacade.getRMTodayVisit(jsonData);
        ResponseUtils.putJsonResponse(response, BaseUtils.succsessObjTimeRespond(result));
    }
}
